﻿@model  DataAccess.Models.Role

<script src="~/Scripts/plugins/jquery.min.js"></script>
<script src="~/Scripts/plugins/layer/layer.min.js"></script>

@section Scripts{
    <script type="text/javascript">

        var index = parent.layer.getFrameIndex(window.name);

        $(function () {

            $("#cancel").click(function () {
                //parent.$("#handle_status").val('1112');
                //alert(parent.$("#handle_status").val());
                //parent.location.reload();
                parent.layer.close(index);
            });

            //$(".chosen-select").chosen();

            $("#submit").bind("click", Save);

        })

        function Save() {
            var name = $.trim($("input[name=name]").val());
            if (name.length == 0) {
                layer.tips('名称不能为空！', 'input[name=name]', { tips: [2, '#78BA32'] });
                return false;
            }
             
            var state = $("#state").val();
            var id = $("#id").val();

            common.invokeApi(
                "post",
                "/editRole.html",
                { id: id, state: state, name: name },
                function () { },
                function (data) {
                    common.msg(data.Message, 1, function () {
                        window.location.href = "/roles.html";
                        //parent.location.reload();
                        //parent.layer.close(index);
                    }); 
                },
                function (data) {
                    common.msg(data.Message, 2, function () { });
                },
                function () { }
                );
        }



    </script>
    <script src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script src="~/Scripts/sys/lib/common_raw.js"></script>
}





<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><a href="#">系统管理</a></li>
                    <li class="active"><span>角色管理</span></li>
                </ol>
                <h1>新增修改角色</h1>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2></h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <form method="post" class="form-horizontal" id="form1">
                            <input type="hidden" id="id" name="id" value="@(Model.id)" />
                            <div class="form-group">
                                <label for="RoleId" class="col-lg-2 control-label">用户名:</label>
                                <div class="col-lg-2">
                                    <input type="text" id="name" name="name" max="10" value="@(Model.name)" class="form-control" placeholder="输入名称">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="state" class="col-lg-2 control-label">状态:</label>
                                <div class="col-lg-2">
                                    <select class="form-control" name="state" id="state">
                                        <option value="1" @(Model.state == 1 ? "selected" : "")>启用</option>
                                        <option value="0" @(Model.state == 0 ? "selected" : "")>禁用</option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group">
                                <div class="col-lg-offset-2 col-lg-10">
                                    @{
                                        if (Model.type == 10 || Model.type == 20 || Model.type == 30)
                                        {
                                            <button class="btn btn-primary" id="submit" type="button" disabled>禁止修改</button>
                                        }
                                        else
                                        {
                                            <button class="btn btn-primary" id="submit" type="button">保 存</button>
                                        }
                                    }
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>




    </div>
</div>